<?php


if (isset($_POST['query'])) {
	
	$query = $_POST['query'];
	
	$sql = "select categoria,precio from se_categorias where categoria like '%($query)%'";
	$array = array();
	
	while ($row = mysql_fetch_assoc(query($sql,0))) {
		$array = $row['categoria'];
	}
	
	echo json_encode($array);
}


Function query($sql,$accion) {
		
		
		require_once '../../includes/appconfig.php';

		$appconfig	= new appconfig();
		$datos		= $appconfig->conexion();	
		$hostname	= $datos['hostname'];
		$database	= $datos['database'];
		$username	= $datos['username'];
		$password	= $datos['password'];

		
		$conex = mysql_connect($hostname,$username,$password) or die ("no se puede conectar".mysql_error());
		
		mysql_select_db($database);
		
		$result = mysql_query($sql,$conex);
		if ($accion && $result) {
			$result = mysql_insert_id();
		}
		mysql_close($conex);
		return $result;
		
	}




?>